package com.dingreading.cloud.admin.util.bean;

import com.dingreading.cloud.admin.entity.CourseTypes;
import com.dingreading.cloud.common.util.NepUtil;

public class CourseUtil {

    public static CourseTypes newMainCourseTypes(
            String courseTypeName, int levelEnd, Integer showOrder, Integer type,
            String cooperationType, String operationType, String subjectType
    ) {
        CourseTypes courseTypes = new CourseTypes();
        courseTypes.setCourseTypeName(courseTypeName);
        courseTypes.setShowOrder(0);
        courseTypes.setShowOrder(showOrder);
        courseTypes.setParentId(0L);
        courseTypes.setLevelEnd(levelEnd);
        courseTypes.setLevelIndex(0);
        courseTypes.setType(type);
        courseTypes.setEnabled(1);
        courseTypes.setCooperationType(NepUtil.nullToZero(cooperationType));
        courseTypes.setOperationType(NepUtil.nullToZero(operationType));
        courseTypes.setSubjectType(NepUtil.nullToZero(subjectType));
        return courseTypes;
    }

    public static CourseTypes newChildCourseTypes(
            Long id, Long subjectMainId, Long parentId, String courseTypeName,
            Integer showOrder, Integer levelEnd, Integer levelIndex, Integer type,
            String operationType, String cooperationType, String subjectType
    ) {
        CourseTypes courseTypes = new CourseTypes();
        if (id != null && id > 0)
            courseTypes.setId(id);
        courseTypes.setCourseTypeName(courseTypeName);
        courseTypes.setMainId(subjectMainId);
        courseTypes.setShowOrder(showOrder);
        courseTypes.setParentId(parentId);
        courseTypes.setLevelEnd(levelEnd);
        if (levelIndex != null)
            courseTypes.setLevelIndex(levelIndex);
        courseTypes.setType(type);
        courseTypes.setEnabled(1);
        courseTypes.setCooperationType(NepUtil.nullToZero(cooperationType));
        courseTypes.setOperationType(NepUtil.nullToZero(operationType));
        courseTypes.setSubjectType(NepUtil.nullToZero(subjectType));
        return courseTypes;
    }

    public static CourseTypes editChildCourseTypes(
            CourseTypes courseTypes, String courseTypeName, String cooperationType, String operationType, String subjectType
    ) {
        if (courseTypeName != null)
            courseTypes.setCourseTypeName(courseTypeName);
        courseTypes.setCooperationType(NepUtil.nullToZero(cooperationType));
        courseTypes.setOperationType(NepUtil.nullToZero(operationType));
        courseTypes.setSubjectType(NepUtil.nullToZero(subjectType));
        return courseTypes;
    }

}
